/*===================通用函数==========================*/
(function(window, $){
	var jftone={
		WEB_SERVER:"",
		IMG_SERVER:"",
		JSONP_CALLBACK:"JFTCB"
	};
	window.JFT=jftone;
	JFT.extend = function() {
		var options, name, src, copy, copyIsArray, clone,target = arguments[0] || {},i = 1,length = arguments.length,deep = false;
		if(typeof target === "boolean") {
			deep = target;
			target = arguments[1] || {};
			i = 2;
		}
		if(typeof(target)!== "object" && !$.isFunction(target)) {
			target = {};
		}
		if (length === i) {
			target = this;
			--i;
		}
		for ( ; i < length; i++ ) {
			if ((options = arguments[ i ]) != null){
				for (name in options ) {
					src = target[name];
					copy = options[name];
					if ( target === copy ) {
						continue;
					}
					if ( deep && copy && ( $.isPlainObject(copy) || (copyIsArray = $.isArray(copy)) ) ) {
						if ( copyIsArray ) {
							copyIsArray = false;
							clone = src && jQuery.isArray(src) ? src : [];
						}else{
							clone = src && $.isPlainObject(src) ? src : {};
						}
						target[ name ] = jQuery.extend( deep, clone, copy );
					}else if( copy !== undefined ){
						target[name] = copy;
					}
				}
			}
		}
		return target;
	};
	JFT.extend({
		each:function(object, callback, args){
		    var name, i = 0, length = object.length,
		        isObj = length === undefined || typeof(object)=="object";
		    if (args){
		        if(isObj){
		            for(name in object){
		                if(callback.apply(object[name], args) === false){
		                    break;
		                }
		            }
		        }else{
		            for( ; i < length; ){
		                if(callback.apply(object[i++], args) === false){ 
		                    break;
		                }
		            }
		        }
		    }else{
		        if(isObj){
		            for(name in object){
		                if(callback.call(object[name], name, object[name]) === false){
		                    break;
		                }
		            }
		        }else{
		            for( ; i < length; ){
		                if(callback.call(object[i], i, object[i++]) === false){
		                    break;
		                }
		            }
		        }
		    }
		    return object;
		}
	});
	
	var verifylib={
		//判断是否为空
		isBlank:function(str){	
			if(str=="" || /^\s+$/.test(str)){
				return true;
			}
			return false;
		},
        checkMobile:function(str) {
            if ("" != str && (!/^1[345789][0-9]{9}$/.test(str))) {
                return false;
            }
            return true;
        },
		//校验字符串等于给定长度
        checkLength: function(str, len) {
            if (str && $.type(str)=="string" && str.length != len) {
                return false;
            }
            return true;
        },
		//校验字符串小于给定长度
        checkMinLength: function(str, len) {
            if (str && $.type(str)=="string" && str.length < len) {
                return true;
            }
            return false;
        },
		//校验字符串大于给定长度
        checkMaxLength: function(str, len) {
            if (str && $.type(str)=="string" && str.length > len) {
                return true;
            }
            return false;
        },
		//校验字符是否为整数
        checkInteger: function(str) {
            if ("" != str && !/^(-|\+)?\d+$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验字符是否为数子
        checkNumber: function(str) {
            return this.checkPInteger(str);
        },
		//校验字符是否为正整
        checkPInteger: function(str) {
            if ("" != str && !/^\d+$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验字符是否为负整数
        checkNInteger: function(str) {
            if ("" != str || !/^-\d+$/.test(str)) {
                return false;

            }
            return true;
        },
		//校验字符是否为数字
        checkNumeric: function(str, format) {
            if ("" != str && !/^(-|\+)?\d+(\.\d+)?$/.test(str)) {
                return false;
            }
            if ("" != str && format && $.type(format)=="string" && format.indexOf(".") != -1 && str) {
                var e = parseFloat(str);
                if (e < 0) {
                    e = -e;
                }
                e = e.toString();
                if (e.indexOf(".") != -1 && (format.length - format.indexOf(".") < e.length - e.indexOf("."))) {
                    return false;
                }
            }
            return true;
        },
		//校验是否为自然数
        checkNature: function(str) {
            if ("" != str && (!/^\d+$/.test(str) || /^[0]/.test(str))) {
                return false;
            }
            return true;
        },
		//校验整数是否在指定范围内
        checkNumberRange: function(str, minStr, maxStr) {
            if ("" != str && parseInt(str) < parseInt(minStr)) {
                return false;
            }
            if ("" != str && parseInt(str) > parseInt(maxStr)) {
                return false;
            }
            return true;
        },
		//校验数字是否在指定范围内
        checkNumbericRange: function(str, minStr, maxStr) {
            if (str && "" != str && minStr != undefined && (parseFloat(str) < parseFloat(minStr))) {
                return false;
            }
            if (str && "" != str && maxStr != undefined && (parseFloat(str) > parseFloat(maxStr))) {
                return false;
            }
            return true;
        },
		//校验时间
        checkDate: function(str, format) {
            if (!str || !format) {
                return true;
            }
            format = $.trim(format);
            var f;
            switch (format) {
            case "yyyy-MM-dd":
            case "yyyy/MM/dd":
                f = /^([1-2]\d{3})(-|\/)([0-1]?[0-9])(-|\/)([0-3]?[0-9])$/;
                break;
            case "HH:mm:ss":
                f = /^(\d{2})(:)?(\d{2})\2(\d{2})$/;
                break;
            case "yyyy-MM-dd HH:mm:ss":
            case "yyyy/MM/dd HH:mm:ss":
                f = /^([1-2]\d{3})(-|\/)([0-1]?[0-9])(-|\/)([0-3]?[0-9])\s(\d{2}):(\d{2}):(\d{2})$/;
                break;
            }
            if (!f) {
                return false;
            }
            return f.test(str);
        },
		//校验email
        checkEmail: function(str) {
            if ("" != str && !/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验文件类型
        checkFile: function(str, ext) {
            if ("" != str && $.type(str)=="string" && ext && $.type(ext)=="string") {
                var files = ext.split(",");
                for (var i = 0; i < files.length; i++) {
                    if (str.toUpperCase().endsWith(files[i].toUpperCase())) {
                        return true;
                    }
                }
                return false;
            }
            return true;
        },
		//校验电话号码
        checkTelephone: function(str) {
            if ("" != str && !/^0[1-9]\d{1,2}\-\d{7,8}$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验电话区号号码
        checkTeleAreaCode: function(str) {
            if ("" != str && !/^0[1-9]\d{1,2}$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验IP地址
        checkIp: function(str) {
            if ("" != str && !/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(str)) {
                return false;

            }
            return true;
        },
		//校验身份证
        checkPspt: function(str) {
        	if ("" != str && !/^\d{6}(19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(str)) {
        		return false;
        	} 
        	//校验地址格式
        	var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
        	if(!city[str.substr(0,2)]){
        		 return false;
        	}
			var code = str.split('');
			//∑(ai×Wi)/(mod 11)
			//加权因子
			var factor = [7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
			//校验位
			var parity = ['1','0','X','9','8','7','6','5','4','3','2'];  //[0,1,2,3,4,5,6,7,8,9,10]
			var sum = 0;
			for (var i = 0; i<17; i++){
				sum += parseInt(code[i]) * factor[i];
			}
			if(parity[sum % 11] != code[17]){
				return false;
			}
			return true;
        },
		//校验是否为人民币格式
        checkRMB: function(str) {
            if ("" != str && !/^[0-9]+(\.[0-9]{1,2})?$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验数字字符
        checkNumChar: function(str) {
            if ("" != str && !/^[a-zA-Z]+\d+[a-zA-Z0-9]*$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验数字，字母，下横杠
        checkStrongChar: function(str) {
            if ("" != str && !/^[A-Z_]+[a-zA-Z0-9_]*$/.test(str)) {
                return false;
            }
            return true;
        },
        checkBaseChar: function(str) {
            if ("" != str && !/^[a-zA-Z0-9_]+$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验大写字符
        checkUpperChar: function(str) {
            if ("" != str && !/^[A-Z]+$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验混合字符
        checkMixChar: function(str) {
            if ("" != str && !/^[a-zA-Z]+[\w\!\@\#\$\&\*\-\+\=\.]*$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验字母字符
        checkLetterChar: function(str) {
            if ("" != str && !/^[a-zA-Z]+$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验数字大写字符
        checkNumUChar: function(str) {
            if ("" != str && !/^[A-Z]+\d+[A-Z0-9]*$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验数字小写字符
        checkNumLChar: function(str) {
            if ("" != str && !/^[a-z]+\d+[a-z0-9]*$/.test(str)) {

                return false;
            }
            return true;
        },
		//校验是否为汉字
        checkChineseChar: function(str) {
            if ("" != str && !/^[\u4e00-\u9fa5]+$/.test(str)) {
                return false;
            }
            return true;
        },
		//校验选中checkbox个数
        checkBoxNum: function(fieldName) {
            var result = false;
			if($("input[name='"+fieldName+"']:checked") 
				&& $("input[name='"+fieldName+"']:checked").length>0) {
				result = true;
			}
             return result;
        }
	},
	format={
		formatDecimal:function(str, n){
			var num = typeof(num)=="string"?parseFloat(str): str;
			var pow = Math.pow(10, n); 
			return Math.round(num*pow)/pow;
		},
		formatRmb:function(str){
			return JFT.formatDecimal(str, 2);
		}
	},
	encrypt=function(code){
		return hex_md5(code);
	},
	//Ajax
	ajax={
		ajaxPost:function(url, param, success){
			if(arguments.length==2){
				this.common(arguments[0], null, "POST", "json", arguments[1]);
			}else if(arguments.length==3){
				this.common(arguments[0], arguments[1], "POST", "json", arguments[2]);
			}
		},
		ajaxGet:function(url, param, success){
			if(arguments.length==2){
				this.common(arguments[0], null, "GET", "json", arguments[1]);
			}else if(arguments.length==3){
				this.common(arguments[0], arguments[1], "GET", "json", arguments[2]);
			}
		},
		ajaxJsonp:function(url, param, success){
			if(arguments.length==2){
				this.common(arguments[0], null, "POST", "jsonp", arguments[1]);
			}else if(arguments.length==3){
				this.common(arguments[0], arguments[1], "POST", "jsonp", arguments[2]);
			}
		},
		common:function(url, param, type, dataType, successFn){
			var setting={};
			setting["url"]= url;
			setting["type"]= type;
			setting["dataType"]= dataType;
			if(dataType == "jsonp"){
				setting["jsonp"]= JFT.JSONP_CALLBACK;
			}
			if(param){
				setting["data"]= param;
			}
			setting["success"]= function(data){
				endPageLoading();
				var code = data["resultCode"];
				if(code == -1){
					alert("系统繁忙，请稍后再试");
					return;
				}else if(code == 99){
					alert("登录超时，请先登录，再进行操作");
					top.location.href = "loginAction.do";
					return;
				}
				if(successFn){
					successFn.apply(this, arguments);
				}
			};
			setting["error"]= function(xhr, textStatus, errorThrown){
				endPageLoading();
				alert("系统繁忙，请稍后再试");
			};
			$.ajax(setting); 
		}
	},
	tools={
		//解析参数串,过滤指定键值
		filterReqParam:function(paramStr,filterKey){
			if(JFT.isBlank(paramStr)) return "";
			if(paramStr.indexOf(filterKey)==-1){
				return paramStr.indexOf("&")==0? paramStr.substr(1): paramStr;
			}
			var params=[];
			var paramArr=paramStr.split("&");
			for(var i=0; i<paramArr.length; i++){
				if(!paramArr[i] || JFT.isBlank(paramArr[i])){
					continue;	
				}
				if(paramArr[i].indexOf(filterKey)==-1){
					params.push(paramArr[i]);
				}
			}
			return params.join("&");
		},
		//解析参数串，获取指定键值
		getReqParam:function(paramStr,searchKey){
			if(paramStr=="") return "";
			if(paramStr.indexOf(searchKey)==-1){
				return "";
			}
			var paramValue="";
			var paramArr=paramStr.split("&");
			for(var i=0; i<paramArr.length; i++){
				if(!paramArr[i] || JFT.isBlank(paramArr[i])){
					continue;	
				}
				if(paramArr[i].indexOf(searchKey)>-1){
					paramValue=(paramArr[i].split("="))[1];
					break;
				}
			}
			return paramValue;
		},
		//截取请求参数串
		getUrlParam:function(paramKey){
			var urlParam = window.location.href;
			var start = urlParam.indexOf("\?");
			if(start == -1){
				return "";
			}
			var paramStr = urlParam.substring(start+1);
			if(!paramStr){
				return paramStr;
			}
			return JFT.getReqParam(paramStr, paramKey);
		},
		getFileSize:function(fileId){
			var elField = null;
			if (fileId.nodeType) {
                elField = fileId;
            } else {
                if (typeof(fileId)=="string") {
                    elField = document.getElementById(fileId);
                } else {
                    if (fileId.length) {
                        elField = fileId[0];
                    }
                }
            }
			var size = -1;
			if(elField.files){
				size = elField.files[0].size;
			}
			return size;
		},
		importJs:function(url){
			var script = document.createElement("script"); 
			script.setAttribute("type", "text/javascript");
			script.setAttribute('src', url);  
			document.getElementsByTagName("head")[0].appendChild(script); 
		},
		//根据毫秒时间转换成Date对象
		getDateWithMisec:function(millisecond){
			var date = new Date();
			date.setTime(millisecond);
			return date;
		}
	},
	browser={
		android:/android/i.test(navigator.userAgent),
		ios:/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent),
		wx:/MicroMessenger/i.test(navigator.userAgent),
		mozilla:/firefox/i.test(navigator.userAgent),
		webkit:/webkit/i.test(navigator.userAgent),
		opera:/opera/i.test(navigator.userAgent),
		msie:/msie/i.test(navigator.userAgent),
		ieVersion:function(){
			if(JFT.browser.msie){
				return 0;
			}
			var ua = navigator.userAgent.toLowerCase();		
			return ua.match(/msie ([\d.]+)/)[1];
		}
	};
	String.prototype.endsWith=function(endFix){
		var pattern = new RegExp(endFix+"$");
		if(pattern.test(this)){
			return true;	
		}
		return false;
	};
	String.prototype.toDate = function(format) {
		var str = this;
		if (!$.trim(str)) {
			return null;
		}
		format = format || "yyyy-MM-dd HH:mm:ss";
		var y4 = "([0-9]{4})";
		var M2 = "(0[1-9]|1[0-2])";
		var M1 = "([1-9]|1[0-2])";
		var d2 = "(0[1-9]|[1-2][0-9]|30|31)";
		var d1 = "([1-9]|[1-2][0-9]|30|31)";
		var H2 = "([0-1][0-9]|20|21|22|23)";
		var H1 = "([0-9]|1[0-9]|20|21|22|23)";
		var m2 = "([0-5][0-9])";
		var m1 = "([0-9]|[1-5][0-9])";
		var s2 = "([0-5][0-9])";
		var s1 = "([0-9]|[1-5][0-9])";
		var reg = format;
		reg = reg.replace(/yyyy/, y4).replace(/MM/, M2).replace(/M/, M1).replace(/dd/, d2).replace(/d/, d1).replace(/HH/, H2).replace(/H/, H1).replace(/mm/, m2).replace(/m/, m1).replace(/ss/, s2).replace(/s/, s1);
		var regexp = new RegExp("^" + reg + "$");
		var isDateStr = regexp.test(str);
		if (isDateStr) {
			var index = 0;
			switch (format) {
            case "yyyy-MM-dd":
            case "yyyy/MM/dd":
                index = 2;
                break;
            case "yyyy-MM-dd HH:mm":
            case "yyyy/MM/dd HH:mm":
                index = 4;
                break;
            case "yyyy-MM-dd HH:mm:ss":
            case "yyyy/MM/dd HH:mm:ss":
                index = 5;
                break;
            }
			var now = new Date();
			var vals = regexp.exec(str);
			var year = index >= 2 ? vals[1] : now.getFullYear();
			var month = index >= 2 ? (vals[2] - 1) : now.getMonth();
			var day = index >= 2 ? vals[3] : now.getDate();
			var hour = index >= 4 ? vals[4] : "";
			var minute = index >= 4 ? vals[5] : "";
			var second = index >= 5 ? vals[6] : "";
			var validate;
			if (hour == "") {
				validate = new Date(year, month, day);
			} else {
				validate = new Date(year, month, day, hour, minute, second);
			}
			if (validate.getDate() == day) {
				return validate;
			}
		} else {
			return null;
		}
	};
	Date.prototype.format = function(fmt) {
		var o = {
			"M+": this.getMonth() + 1,
			"d+": this.getDate(),
			"h+": this.getHours() % 12 == 0 ? 12: this.getHours() % 12,
			"H+": this.getHours(),
			"m+": this.getMinutes(),
			"s+": this.getSeconds(),
			"q+": Math.floor((this.getMonth() + 3) / 3),
			"S": this.getMilliseconds()
		};
		var week = {
			"0": "\u65e5",
			"1": "\u4e00",
			"2": "\u4e8c",
			"3": "\u4e09",
			"4": "\u56db",
			"5": "\u4e94",
			"6": "\u516d"
		};
		if (/(y+)/.test(fmt)) {
			fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		}
		if (/(E+)/.test(fmt)) {
			fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "\u661f\u671f": "\u5468") : "") + week[this.getDay() + ""]);
		
		}
		for (var k in o) {
			if (new RegExp("(" + k + ")").test(fmt)) {
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			}
		}
		return fmt;
	};
	//DataMap
	JFT.DataMap=function(str){
		this.map = {};
		this.length = 0;
		if(str){
			var obj = null;	
			if(typeof(str)=="string"){
				obj = str.indexOf("&")>=0? this.formatObject(str):JSON.parse(str);	
			}else{
				obj = str;	
			}
			this.parseObject(obj);
		}
	};
	JFT.DataMap.prototype={
		get:function(key, defaultValue) {
			var ret = this.map[key];
			if (arguments.length > 1 && (typeof(ret) == "undefined" || ret == null)) {
				return defaultValue;
			}
			return ret;
		},
		put:function(key, value){
			if (arguments.length == 1) {
				value = arguments[0];
				key = value["id"];
			}
			if(!this.map[key]) {
				this.length++;
			}
			this.map[key] = value;
		},
		putAll:function(obj){
			if (arguments.length > 1 || obj instanceof Array) {
				var args = arguments.length > 1 ? arguments: obj;
				for (var i = 0, len = args.length; i < len; i++) {
					this.add(args[i]);
				}
			} else {
				for (var key in obj) {
					this.put(key, obj[key]);
				}
			}
		},
		remove:function(value){
			for(var key in this.map){
				if(this.map[key] == value){
					delete this.map[key];
					this.length--;
				}	
			}
		},
		removeKey:function(key){
			delete this.map[key];
			this.length--;
		},
		clear:function(){
			this.map={};
			this.length=0;
		},
		each:function(fn, scope){
			var i = 0;
			for(var key in this.map){
				if(fn.call(scope || window, key, this.map[key], i) === false) {
					break;
				}
				i++;
			}	
		},
		has:function(value){
			var flag = false;
			for(var key in this.map){
				if(this.map[key] == value){
					flag = true;
					break;
				}	
			}
			return flag;
		},
		hasKey:function(key){
			return this.map[key]? true : false;
		},
		clone:function(){
			var copy = new JFT.DataMap();
			this.each(function(key, value){
				copy.put(key, value);
			});	
			return key;
		},
		formatObject: function(str) {
			var obj = {};
			var params = data.split("&");
			var tmp=null;
			for(var i=0, len=params.length; i<len; i++){
				if(JFT.isBlank(params[i])) continue;
				tmp = params[i].split("=");
				obj[tmp[0]] = tmp[1];
			}
			return obj;
		},
		parseObject: function(obj) {
			var tmp = null;
			for (var key in obj) {
				tmp = obj[key];
				if (tmp && $.isArray(tmp)) {
					this.put(key, new JFT.DataList(tmp));
				} else {
					if (tmp && $.isPlainObject(tmp)) {
						this.put(key, new JFT.DataMap(tmp));
					} else {
						this.put(key, (tmp == undefined || tmp == null) ? "": tmp);
					}
				}
			}
		}
	};
	JFT.DataMap.prototype.toString = function() {
		var str=[],tmp=null,value=null;
		for(var k in this.map){
			tmp=this.map[k];
			if(tmp instanceof JFT.DataMap || tmp instanceof JFT.DataList){
				value = tmp.toString();
			}else if($.isArray(tmp) || $.isPlainObject(tmp)){
				value = JSON.stringify(tmp);
			}else if(typeof(tmp) == "object" && tmp instanceof Array) {	//[1,2,3]
				value = tmp.toString;
			} else if(typeof(tmp) == "string"){
				value = '"'+tmp.replace(/\"/g, '\\"')+'"';
			}else{
				value = tmp;
			}
			str.push('"'+k+'":'+value);
		}
		return "{"+str.join(",")+"}";
	};
	
	//DataList
	JFT.DataList = function(objs) {
		this.items = [];
		this.length = 0;
		if (typeof(objs) == "string" && objs != "") {
			var list = JSON.parse(objs);
			if(list) this.parseArray(list);
		}else if (typeof(objs) == "object" && (objs instanceof Array) && objs.length) {
			this.parseArray(objs);
		}
	};
	JFT.DataList.prototype = {
		add:function(obj) {
			this.items.push(obj);
			this.length++;
		},
		get:function(index, key, defaultValue) {
			if (index < this.length && index >= 0) {
				var ret = this.items[index];
				if(arguments.length<2){
					return ret;
				}
				if ((typeof(ret) != "undefined") && (ret instanceof JFT.DataMap) && typeof(arguments[1]) == "string" && arguments[1] != "") {
					return ret.get(key, defaultValue);
				}
			}
			return null;
		},
		each:function(fn, scope) {
			var items = [].concat(this.items);
			for (var i = 0, len = items.length; i < len; i++) {
				if (fn.call(scope || window, items[i], i) === false) {
					break;
				}
			}
		},
		remove:function(obj) {
			return this.removeAt(this.indexOf(obj));
		},
		removeAt:function(index) {
			if (index < this.length && index >= 0) {
				this.items.splice(index, 1);
				this.length--;
			}
		},
		indexOf:function(obj) {
			if (!this.items.indexOf) {
				for (var i = 0, len = this.items.length; i < len; i++) {
					if (this.items[i] == obj) {
						return i;
					}
				}
				return - 1;
			} else {
				return this.items.indexOf(obj);
			}
		},
		parseArray: function(objs) {
			var tmp = null;
			for (var i = 0; i < objs.length; i++) {
				tmp = objs[i];
				if (tmp && $.isArray(tmp)) {
					this.add(new JFT.DataList(tmp));
				} else {
					if (tmp && $.isPlainObject(tmp)) {
						this.add(new JFT.DataMap(tmp));
					} else {
						if (tmp != undefined && tmp != null) {
							this.add(tmp);
						}
					}
				}
			}
		},
		clear: function() {
			this.items = [];
			this.length = 0;
		}
	};
	JFT.DataList.prototype.toString = function() {
		var str=[];
		this.each(function(item, i){
			if(item instanceof JFT.DataMap || item instanceof JFT.DataList){
				str.push(item.toString());
			}else{
				str.push(JSON.stringify(item));
			}
		});
		return "["+str.join(",")+"]";
	};
	
	JFT.extend({
		session:{
			support:function(){
				return window["sessionStorage"]? true : false;
			},	
			put:function(key, value){
				var str = null;
				if(value instanceof JFT.DataMap || value instanceof JFT.DataList){
					str = value.toString();
				}else if($.isArray(value) || $.isPlainObject(value)){
					str = JSON.stringify(value);
				}else{
					str = value;
				}
				sessionStorage.setItem(key, str);
			},	
			get:function(key){
				return sessionStorage.getItem(key);
			},	
			getJson:function(key){
				return JSON.parse(sessionStorage.getItem(key));
			},	
			getMap:function(key){
				return new JFT.DataMap(sessionStorage.getItem(key));
			},	
			getList:function(key){
				return new JFT.DataList(sessionStorage.getItem(key));
			},	
			remove:function(key){
				sessionStorage.removeItem(key);
			},	
			clear:function(){
				sessionStorage.clear();
			},	
			length:function(){
				return sessionStorage.length;
			},
			each:function(fn, scope){
				var key=null,storage = window.sessionStorage;
				for (var i = 0, len = storage.length; i < len; i++) {
					key = storage.key(i);
					if (fn.call(scope || window, key, storage.getItem(key), i) === false) {
						break;
					}
				}
			}
		},
		local:{
			support:function(){
				return window["localStorage"]? true : false;
			},	
			put:function(key, value){
				var str = null;
				if(value instanceof JFT.DataMap || value instanceof JFT.DataList){
					str = value.toString();
				}else if($.isArray(value) || $.isPlainObject(value)){
					str = JSON.stringify(value);
				}else{
					str = value;
				}
				localStorage.setItem(key, str);
			},	
			get:function(key){
				return localStorage.getItem(key);
			},	
			getJson:function(key){
				return JSON.parse(localStorage.getItem(key));
			},	
			getMap:function(key){
				return new JFT.DataMap(localStorage.getItem(key));
			},	
			getList:function(key){
				return new JFT.DataList(localStorage.getItem(key));
			},	
			remove:function(key){
				localStorage.removeItem(key);
			},	
			clear:function(){
				localStorage.clear();
			},	
			length:function(){
				return localStorage.length;
			},
			each:function(fn, scope){
				var key=null,storage = window.localStorage;
				for (var i = 0, len = storage.length; i < len; i++) {
					key = storage.key(i);
					if (fn.call(scope || window, key, storage.getItem(key), i) === false) {
						break;
					}
				}
			}
		}	
	});
	
	JFT.extend(verifylib);
	JFT.extend(format);
	JFT.extend(tools);
	JFT.browser=browser;
	JFT.encrypt=encrypt;
	window.DataMap = JFT.DataMap;
	window.DataList = JFT.DataList;
	for(var k in ajax){
		window[k]=ajax[k];
	}

})(window, jQuery);

//扩展组件
(function($){
	//扩展组件
	$.fn.extend({
		bindNumber:function(){
			$(this).focus(function(){
				$(this).css("ime-mode", "disabled");
			});
			$(this).keypress(function(e){
				var value = $(this).val();
				//控制第一个不能输入小数点"."  
			    if (value.length == 0 && e.which == 46) {  
			        event.preventDefault();  
			        return false;  
			    }  
				if (((e.which > 47) && (e.which < 58)) || (e.which == 8) || (e.which == 17) || (e.which == 46)) {  
					return true;  
				}else{ 
					e.preventDefault();
					return false;  
				}  
			});
		},
		//组织冒泡事件及默认事件
		mbind:function(eventType, func) {
			$(this).bind(eventType, function(evt){
				evt.stopPropagation();
				evt.preventDefault();
				func.apply(this, arguments);
			});
		},
		//jquery触摸事件
		touch:function(func) {
			$(this).mbind("tap", func);
		},
		untouch:function() {
			$(this).unbind("tap");
		},
		//jquery触摸并保持一秒
		touchHold:function(func) {
			$(this).mbind("taphold", func);
		},
		untouchHold:function() {
			$(this).unbind("taphold");
		},
		//jquery水平滑动事件
		swipe:function(func) {
			$(this).mbind("swipe", func);
		},
		unswipe:function() {
			$(this).unbind("swipe");
		},
		//jquery向左滑动事件
		swipeLeft:function(func) {
			$(this).mbind("swipeleft", func);
		},
		unswipeLeft:function() {
			$(this).unbind("swipeleft");
		},
		//jquery向右滑动事件
		swipeRight:function(func) {
			$(this).mbind("swiperight", func);
		},
		unswipeRight:function() {
			$(this).unbind("swiperight");
		}
	});
	$.extend({});
})(jQuery);

(function(jft){
	var tmplCache={};
	jft.extend({
		//判断电信运行商
		getTelOperator:function(serialNumber){
			var str = "未知运营商";
			var chinaMobile = /^134[0-8]\d{7}$|^(?:13[5-9]|147|15[0-27-9]|178|18[2-478])\d{8}$/;
			var chinaUnion = /^(?:13[0-2]|145|15[56]|176|18[56])\d{8}$/;
			var chinaTelcom = /^(?:133|153|177|18[019])\d{8}$/;
			var otherTelphone  = /^170([059])\d{7}$/;
			
			if(chinaMobile.test(serialNumber)){
        		str = "中国移动";
			}
			else if(chinaUnion.test(serialNumber)){
				str = "中国联通";
			}
			else if(chinaTelcom.test(serialNumber)){
				str = "中国电信";
			}
			else if(otherTelphone.test(serialNumber)){
				str = "其他运营商";
			}
			return str;
		},
		
		//渲染模板
		templet:function(tmpId,json){
			var fn = null;
			if(tmplCache[tmpId]){
				fn = tmplCache[tmpId];
			}else{
				var str = $("#"+tmpId).html();
				fn = new Function("obj",  
					"var p=[]; with(obj){p.push('" + 
					str.replace(/[\r\t\n]/g, " ") 
					  .split("<%").join("\t")  
					  .replace(/((^|%>)[^\t]*)'/g, "$1\r")  
					  .replace(/\t=(.*?)%>/g, "',$1,'")  
					  .split("\t").join("');")  
					  .split("%>").join("p.push('")  
					  .split("\r").join("\\'")  
				  + "');}return p.join('');");
				str = null;  
				tmplCache[tmpId] = fn;
			}
			return json? fn(json) : fn();
		},	
		templetList:function(tmpId,jsons){
			if(!$.isArray(jsons)){
				return this.templet(tmpId,jsons);
			}
			var html=[];
			for(var i=0; i<jsons.length; i++){
				html.push(this.templet(tmpId,jsons[i]));
			}
			return html.join("");
		}
	});
})(JFT);


/*
 * 页面校验
 */
(function(JFT) {
	JFT.validate = {
		checkCompare:function(el, elField, fieldName, value, isInt){
			var min = el.attr("min");
            var max = el.attr("max");
            var result = false;
            if(min){
            	result = isInt?parseInt(value)<parseInt(min) : parseFloat(value)<parseFloat(min);
            	if(result){
            		JFT.validate.alert(fieldName+"不能小于"+min, elField);
                    return false;
            	}
            }
            if(max){
            	result = isInt?parseInt(value)>parseInt(max) : parseFloat(value)>parseFloat(max);
            	if(result){
            		JFT.validate.alert(fieldName+"不能大于"+max, elField);
                    return false;
            	}
            }
            return true;
		},
        verifyField: function(fieldId) {
            var elField;
            if (!fieldId) {
                return false;
            }
            if (fieldId.nodeType) {
                elField = fieldId;
            } else {
                if ($.type(fieldId)=="string") {
                    elField = document.getElementById(fieldId);
                } else {
                    if (fieldId.length) {
                        elField = fieldId[0];
                    }
                }
            }
            if (!elField || !elField.nodeType) {
                alert("找不到Dom元素：" + fieldId);
                return false;
            }
            var el = $(elField);
            var fieldName = el.attr("desc"),
            nullable = el.attr("nullable"),
            tagName = elField.nodeName,
            value = el.val();
            if ($.type(value)=="string") {
                value = $.trim(value);
                el.val(value);
            }
            if (!fieldName) {
                JFT.validate.alert("Dom元素"+elField.toString()+"未配置desc!", elField);
                return false;
            }
            if("no" == nullable && (!value || "" == value)) {
            	JFT.validate.alert(fieldName+(tagName=="SELECT"? "为必选项" : "不能为空")+"！", elField);
    			return false;
            }else if(!value || "" == value){
            	return true;
            }
            if("no" == nullable && ("checkbox" == el.attr("type") || "radio" == el.attr("type"))) {
				if (!JFT.checkBoxNum(el.attr("name"))) {
					JFT.validate.alert(fieldName+"为必选项", elField);
					return false;
				}
            }
			if(el.attr("equal") && $("#"+el.attr("equal")).attr("desc")) {
				var equalEl = $("#"+el.attr("equal"));
				if(equalEl.val()!=value){
					JFT.validate.alert(fieldName+"和"+equalEl.attr("desc")+"必须相同！", elField);
					return false;
				}
			}
			if(el.attr("unequal") && $("#"+el.attr("unequal")).attr("desc")) {
				var unequalEl = $("#"+el.attr("unequal"));
				if(unequalEl.val()!=value){
					JFT.validate.alert(fieldName+"和"+unequalEl.attr("desc")+"不能相同！", elField);
					return false;
				}
			}
            if (el.attr("len") && !JFT.checkLength(value, el.attr("len"))) {
				JFT.validate.alert(fieldName+"长度必须等于"+el.attr("len")+"个字符!", elField);
                return false;
            }
            if (el.attr("minlen") && JFT.checkMinLength(value, el.attr("minlen"))) {
				JFT.validate.alert(fieldName+"最小长度为"+el.attr("minlen")+"个字符!", elField);
                return false;
            }
            if (el.attr("maxlen") && JFT.checkMaxLength(value, el.attr("maxlen"))) {
				JFT.validate.alert(fieldName+"最大长度为"+el.attr("maxlen")+"个字符!", elField);
                return false;
            }
            var m;
            switch (el.attr("datatype")) {
            case "integer":
                if (!JFT.checkInteger(value)) {
                    JFT.validate.alert(fieldName+"必须为整数!", elField);
                    return false;
                }
                if(!JFT.validate.checkCompare(el, elField, fieldName, value, true)){
                	return false;
                }
                break;
            case "pinteger":
                if (!JFT.checkPInteger(value)) {
                    JFT.validate.alert(fieldName+"必须为正整数!", elField);
                    return false;
                }
                if(!JFT.validate.checkCompare(el, elField, fieldName, value, true)){
                	return false;
                }
                break;
            case "ninteger":
                if (!JFT.checkNInteger(value)) {
                    JFT.validate.alert(fieldName+"必须为负整数!", elField);
                    return false;

                }
                if(!JFT.validate.checkCompare(el, elField, fieldName, value, true)){
                	return false;
                }
                break;
			case "number":		// 纯数字
                if (!JFT.checkNumber(value)) {
                    JFT.validate.alert(fieldName+"必须为数字!", elField);
                    return false;
                }
                if(!JFT.validate.checkCompare(el, elField, fieldName, value, true)){
                	return false;
                }
                break;
            case "numeric":		// 纯数字小数点，正负符号
            	var decimalStr = "";
            	var fmt = el.attr("format");
            	if(fmt && fmt.indexOf(".") != -1){
            		decimalStr="，必须为整数或保留"+(fmt.length-fmt.indexOf(".")-1)+"位小数以内";
            	}
                if (!JFT.checkNumeric(value, fmt)) {
                    JFT.validate.alert(fieldName+"必须为数字"+decimalStr+"!", elField);
                    return false;
                }
                if(!JFT.validate.checkCompare(el, elField, fieldName, value, false)){
                	return false;
                }
                break;
            case "nature":
                if (!JFT.checkNature(value)) {
                    JFT.validate.alert(fieldName+"必须为自然数!", elField);
                    return false;
                }
                if(!JFT.validate.checkCompare(el, elField, fieldName, value, true)){
                	return false;
                }
                break;
            case "date":
                var format = el.attr("format");
                if (format && !JFT.checkDate(value, format)) {
					JFT.validate.alert(fieldName+"格式不对，必须是(" + format + ")!", elField);
                    return false;
                }
                var minName = el.attr("minName");
                var maxName = el.attr("maxName");
                var min = el.attr("min");
                var max = el.attr("max");
                if (value && format) {
                    var curDate = value.toDate(format);
                    var minValue,minDate,minEl,minDesc,maxValue,maxDate,maxEl, maxFieldDesc;
                    if (minName && (minEl = $("#" + minName)) && minEl.val() && minEl.attr("desc")) {
                        minValue = minEl.val();
                        minDate = minValue.toDate(format);
                        minDesc = minEl.attr("desc");
                    }
                    if (min) {
                        minValue = min.toDate(format);
                        minDate = ((minDate && minValue < minDate) ? minDate: minValue);
                        minDesc = ((minDesc && minValue < minDate) ? minDesc: min);
                    }
                    if (minDate && minDesc && curDate < minDate) {
						JFT.validate.alert(fieldName+"不能小于" + minDesc, elField);
                        return false;
                    }
                    if (maxName && (maxEl = $("#" + maxName)) && maxEl.val() && maxEl.attr("desc")) {
                        maxValue = maxEl.val();
                        maxDate = maxValue.toDate(format);
                        maxFieldDesc = maxEl.attr("desc");
                    }
                    if (max) {
                        maxValue = max.toDate(format);
                        maxDate = ((maxDate && maxValue > maxDate) ? maxDate: maxValue);
                        maxFieldDesc = ((maxFieldDesc && maxValue > maxDate) ? maxFieldDesc: max);
                    }
                    if (maxDate && maxFieldDesc && curDate > maxDate) {
						JFT.validate.alert(fieldName+"不能大于" + maxFieldDesc, elField);
                        return false;
                    }
                }
                break;
            case "email":
                if (!JFT.checkEmail(value)) {
                    JFT.validate.alert(fieldName+"不符合电子邮件格式!", elField);
                    return false;
                }
                break;

            case "file":
                if (!JFT.checkFile(value, el.attr("extname"))) {
					JFT.validate.alert(fieldName+"格式不对，必须是(" + el.attr("extname") + ")!", elField);
                    return false;
                }
                break;
            case "phone":
                if (!JFT.checkTelephone(value)) {
                    JFT.validate.alert(fieldName+"格式不对!", elField);
                    return false;
                }
                break;
            case "mobile":
                if (!JFT.checkMobile(value)) {
                    JFT.validate.alert(fieldName+"格式不对!", elField);
                    return false;
                }
                break;
            case "pspt":
            	if (!JFT.checkPspt(value)) {
                    JFT.validate.alert(fieldName+"格式不对!", elField);
                    return false;
                }
                break;
            case "ip":
                if (!JFT.checkIp(value)) {
                    JFT.validate.alert(fieldName+"格式不对!", elField);
                    return false;
                }
                break;
            case "char":
                if (!JFT.checkLetterChar(value)) {
                    JFT.validate.alert(fieldName+"必须是英文字母!", elField);
                    return false;
                }
                break;
            case "strongchar":
                if (!JFT.checkStrongChar(value)) {
                    JFT.validate.alert(fieldName+"必须是大写字母或下横杠开头的字母或数字组合!", elField);
                    return false;
                }
                break;
            case "numchar":
                if (!JFT.checkNumChar(value)) {
                    JFT.validate.alert(fieldName+"必须是字母和数字组合!", elField);
                    return false;
                }
                break;				
            case "upperchar":
                if (!JFT.checkUpperChar(value)) {
                    JFT.validate.alert(fieldName+"必须是大写字母!", elField);
                    return false;
                }
                break;
            case "numuchar":
                if (!JFT.checkNumUChar(value)) {
                    JFT.validate.alert(fieldName+"必须是大写字母和数字组合!", elField);
                    return false;

                }
                break;
            case "numlchar":
                if (!JFT.checkNumLChar(value)) {
                    JFT.validate.alert(fieldName+"必须是小写字母和数字组合!", elField);
                    return false;
                }
                break;
            case "basechar":
                if (!JFT.checkBaseChar(value)) {
                    JFT.validate.alert(fieldName+"必须字母或数字!", elField);
                    return false;
                }
                break;
            case "mixchar":
                if (!JFT.checkMixChar(value)) {
                    JFT.validate.alert(fieldName+"必须字母开头，字母、数字或特殊字符[!,@,#,$,&,*,-,+,=,_,.]组合!", elField);
                    return false;
                }
                break;
            case "chinese":
                if (!JFT.checkChineseChar(value)) {
                    JFT.validate.alert(fieldName+"必须为中文汉字!", elField);
                    return false;
                }
                break;
            }
            return true;
        },
		//校验所有form表单控件
        verifyAll: function(partId) {
			if (undefined == partId) {
				partId = document;
			}
			var els = null;
			if (partId && partId.nodeType) {
				els = $("*[desc]", partId).toArray();
			} else {
				if ($.type(partId)=="string") {
					els = $("#" + partId + " *[desc]").toArray();
				}
			}
			var result=true;
			if (els && els.length) {
				var el;
				for (var i = 0; i < els.length; i++) {
					el = els[i];
					if (el.disabled) {
						continue;
					}
					if (!$.attr(el, "desc")) {
						continue;
					}
					if (!JFT.validate.verifyField(el)) {
						result = false;
					}
					if (!result) {
						return false;
					}
				}
			}
			els = null;
			return result;
        }
    };
	JFT.validate.alert = function(info, fieldId) {
		alert(info);
		if (fieldId && fieldId.nodeType) {
			//$(fieldId).focus();
			$(fieldId).addClass("e_error");
		}
	};
})(JFT);

//页面组件模块
(function(JFT){
	JFT.extend({
		//弹出页面加载框
		popupPage:function(url, title, pw, ph, func){
			var width=640,height=560;
			if(arguments.length == 3){
				func = arguments[2]; 
			}else{
				if(pw && JFT.checkNumber(pw)) width = pw;
				if(ph && JFT.checkNumber(ph)) height = ph;
			}
			var pageHtml = [];
			pageHtml.push('<div id="pageOverlay" class="c_overlay"></div>');
			pageHtml.push('<div id="_POPUPPAGE" class="c_alert-form" style="width:'+width+'px;height:'+height+'px">');
			pageHtml.push('<div class="head">');
			pageHtml.push('<div class="topic">'+title+'</div><div name="closeIcon" class="close" title="关闭窗口"></div>');
			pageHtml.push('</div>');
			pageHtml.push('<iframe src="'+url+'" frameborder="0" style="width:'+( width - 40)+'px;height:'+( height-140)+'px"></iframe>');
			pageHtml.push('<div class="e_center">');
			pageHtml.push('<button name="confirmBtn" type="button" class="e_btn">确定</button>');
			pageHtml.push('<button name="closeBtn" type="button" class="e_btn-form l_ml">关闭</button>');
			pageHtml.push('</div>');
			pageHtml.push('</div>');
			$(document.body).append(pageHtml.join(""));
			pageHtml = null;
			var popWin = $("#_POPUPPAGE");
			popWin.css({
				"margin-left":(-popWin.width()/2)+"px",
				"margin-top":(-popWin.height()/2)+"px"
			}).fadeIn();
			popWin.find("div[name=closeIcon]").bind("click", function(){
				$(this).unbind("click");
				popWin.find("button[name=confirmBtn],button[name=closeBtn]").unbind("click");
				if($("#_POPUPPAGE").length){
					$("#_POPUPPAGE").remove();
				}
				if($("#pageOverlay").length){
					$("#pageOverlay").remove();
				}
			});
			popWin.find("button[name=confirmBtn]").click(function(){
				var iframeObj = popWin.find("iframe");
				if(iframeObj[0].contentWindow.setPopupValue && 
						typeof(iframeObj[0].contentWindow.setPopupValue) == "function"){
					var resultObj=(new Function(" var iframeObj = $('#_POPUPPAGE iframe')[0]; return iframeObj.contentWindow.setPopupValue();"))();
					if(!resultObj){
						return;	
					}
					if(func) {
						func.call(this, resultObj);
					}else{
						if($.type(resultObj)=="object"){
							var el = null;
							for(var key in resultObj){
								el = $("#"+key);
								if(!el || !el.length) continue;
								el.val(resultObj[key]);	
							}
						}
					}
				}
				popWin.find("div[name=closeIcon]").trigger("click");
			});
			popWin.find("button[name=closeBtn]").click(function(){
				popWin.find("div[name=closeIcon]").trigger("click");
			});
		},
		showPage:function(url, title, pw, ph){
			var width=800,height=560;
			if(pw && JFT.checkNumber(pw)) width = pw;
			if(ph && JFT.checkNumber(ph)) height = ph;
			var pageHtml = [];
			pageHtml.push('<div id="pageOverlay" class="c_overlay"></div>');
			pageHtml.push('<div id="_POPUPPAGE" class="c_alert-form" style="width:'+width+'px;height:'+height+'px">');
			pageHtml.push('<div class="head">');
			pageHtml.push('<div class="topic">'+title+'</div><div name="closeIcon" class="close" title="关闭窗口"></div>');
			pageHtml.push('</div>');
			pageHtml.push('<iframe src="'+url+'" frameborder="0" style="width:'+( width - 40)+'px;height:'+( height-80)+'px"></iframe>');
			pageHtml.push('</div>');
			$(document.body).append(pageHtml.join(""));
			pageHtml = null;
			var popWin = $("#_POPUPPAGE");
			popWin.css({
				"margin-left":(-popWin.width()/2)+"px",
				"margin-top":(-popWin.height()/2)+"px"
			}).fadeIn();
			popWin.find("div[name=closeIcon]").bind("click", function(){
				$(this).unbind("click");
				if($("#_POPUPPAGE").length){
					$("#_POPUPPAGE").remove();
				}
				if($("#pageOverlay").length){
					$("#pageOverlay").remove();
				}
			});
		}
	});
})(JFT);

/*=====================Web管理页面绑定函数=======================*/


(function(JFT){
	//页面加载效果
	var pageload = {
		beginPageLoading:function(flag){
			var html = [];
			if(!flag){
				html.push('<div id="pageLoading" class="c_loading">');
				html.push('<span id="loading_txt"></span>');
				html.push("</div>");
			}
			html.push('<div id="pageOverlay" class="c_overlay"></div>');
			$(document.body).append(html.join(""));
			html = null;
		},
		
		endPageLoading:function(){
			if($("#pageLoading").length){
				$("#pageLoading").remove();
			}
			if($("#pageOverlay").length){
				$("#pageOverlay").remove();
			}
		}
	},
	pageBind={
		initPageEvent:function(){
			$("#PAGE_NO").bindNumber();
			$("#PAGE_NO").keypress(function(evt){
				if(evt.which==13){
					$("#PAGE_BTN").trigger("click");
					return false;
				}
				return true;
			});
			$("#PAGE_BTN").click(function(){
				var curPage = $("#PAGE_NO").val();
				if(JFT.isBlank(curPage) || !JFT.checkNumber(curPage)){
					alert("输入页数有错误,请确认!");
					$("#PAGE_NO").val("1");
					$("#PAGE_NO").focus();
					return ;
				}
				JFT.PageBind.redirect(curPage);
			});
			
			$("#PAGE_PART a[data]").click(function(){
				JFT.PageBind.redirect($(this).attr("data"));
			});
		},
		redirect:function(curPage){
			var method = JFT.getUrlParam("method");
			var pageUrl = "?method="+method;
			if($("#queryParams") && $("#queryParams").length){
				pageUrl+=$("#queryParams").val();
			}
			location.href = pageUrl+"&curPage="+curPage;
		}
	},
	
	btnBind = {
		btnBind:"bind",

		//绑定按钮事件
		initFuncBtnEvent:function(){
			var actionCmd = $(this).attr(JFT.BtnBind.btnBind);
			var bindForm = $(this).attr("bindForm");
			if(actionCmd == "oper"){
				//功能操作按钮
				JFT.BtnBind.initOperBtnEvent($(this).attr("name"));
				return;	
			}else if(actionCmd == "clear"){
				//清除按钮
				JFT.BtnBind.initClearBtnEvent(bindForm);
				return;	
			}
			var formObj = null;
			if(!bindForm || JFT.isBlank(bindForm)){
				formObj = $(this).parents("form")[0];
			}else{
				formObj = document.getElementById(bindForm);	
			}
			if(formObj.nodeName.toUpperCase() != "FORM"){
				 return;	
			}
			//校验内部控件数据
			if(!JFT.validate.verifyAll(formObj)){
				return;	
			}
			var action=$(this).attr("tradeAction");
			var result=true;
			if(action && action.length){
				result=(new Function("return "+action+";"))();
			}
			if(!result) {
				return;
			}
			var action = $(formObj).attr("action");
			formObj.action= !action || JFT.isBlank(action)? "?method="+actionCmd : action;
			formObj.submit();
		},
		initClearBtnEvent:function(bindForm){
			var tagName = null,type = null;
			$("#"+bindForm).find("input,textarea,select").each(function(index, ele){
				tagName = ele.tagName;
				if(tagName == "SELECT"){
					$(ele).find("option:first").prop("selected", 'selected');
					return true;
				}else if(tagName == "TEXTAREA"){
					$(ele).val("");
					return true;
				}
				type = $(ele).attr("type");
				if(type == "radio" || type == "checkbox"){
					$(ele).prop("checked", false);
					return;
				}else if(type != "button" && type != "reset" && type != "submit"){
					$(ele).val("");
				}
			});
		},
		initOperBtnEvent:function(btn){
			var btnEl = $("#"+btn);
			var tag=btnEl.attr("tag");
			var cmd=btnEl.attr("cmd");
			var limit=btnEl.attr("limit");
			var checkName = JFT.TableBind.checkBoxName;
			var checkObj = JFT.TableBind.getCheckBox(checkName);
			if(limit == "1"){
				if(checkObj.count !=1){
					alert("请先选择一条操作的记录！");
					return;
				}
			}else if(limit == "2"){
				if(checkObj.count <1){
					alert("请先选择操作的记录！");
					return;
				}
			}
			//如果为js跳转，则执行js动作
			if(!JFT.isBlank(cmd) && tag == "2"){
				(new Function(cmd))();
				return;
			}
			var param="";
			if($("#queryParams") && $("#queryParams").length){
				param+=$("#queryParams").val();	
			}
			if($("#curPage") && $("#curPage").length){
				param+="&curPage="+$("#curPage").val();	
			}
			var method = "query";
			switch(btn){
				case "ADD_BTN":
					method = "add";
					break;
				case "EDIT_BTN":	
					method = "edit";
					break;
				case "DEL_BTN":		
					if(!window.confirm("是否删除选中记录？")) return;
					method = "delete";
					break;
				case "RIGHT_BTN":	
					method = "confAuth";
					break;
				case "PWD_BTN":		
					method = "modifyKey";
					break;
				case "AUDIT_BTN":	
					method = "audit";
					break;
				case "UNAUDIT_BTN":		
					method = "unAudit";
					break;
				default:
					method = "query";
			}
			var urlStr = (JFT.isBlank(cmd)? "?method="+method : cmd) + param;
			if(checkObj.count>0){
				urlStr += "&"+checkName +"="+checkObj.value;
			}
			location.href = urlStr;
		}
	},
	dataBind = {
		checkBoxName:"dataId",
		checkAllId:"checkedAll",
		initTableEvent:function(checkAllId, checkboxName, trEL){
			var curCheckbox = trEL.find("input[type=checkbox]");
			if(!curCheckbox || !curCheckbox.length){
				return;	
			}
			var flag = curCheckbox.prop("checked")? true: false;								  
			curCheckbox.prop("checked", !flag);
			JFT.TableBind.changeTrStyle(trEL , !flag);
			JFT.TableBind.changeCheckBox(checkAllId, checkboxName, !flag);	
		},
		
		//表格选择样式变化
		changeTrStyle : function(trEl, flag){
			if(flag){
				trEl.addClass("selected");
			}else {
				trEl.removeClass("selected");
			}
		},
		
		//判断选中记录数
		getCheckBox : function(objName, flag){
			var count = 0;
			var flag = (flag==undefined || flag!=false)? true : false;
			var objArray = new Array();
			var checkedBox = flag? $("input[name="+objName+"]:checked") : $("input[name="+objName+"]");
			if(checkedBox){
				checkedBox.each(function(){
					objArray.push($(this).val());
				});
				count = checkedBox.length;
			}checkedBox=null;
			return {"count":count, "value":objArray.join(",")};
		},
		_getCheckValue : function(checkedBox){
			var retList = [];
			var tmpName = null;
			checkedBox.parents("tr").each(function(idx, domEl){
				var obj = {};
				$(domEl).find("td").each(function(){
					tmpName = $(this).attr("name");
					if(!tmpName || JFT.isBlank(tmpName)) return true;
					obj[tmpName] = $(this).attr("data")? $(this).attr("data") : $(this).html();
				});
				retList.push(obj);
			});
			tmpName = null;
			return retList;
		},
		//判断选中记录数
		getCheckObject : function(objName){
			var checkedBox = $("input[name="+objName+"]:checked");
			if(!checkedBox || checkedBox.length!=1){
				alert("请选择一条记录！");
				return false;
			}
			var list = this._getCheckValue(checkedBox);
			checkedBox=null;
			return list[0];
		},
		
		//判断选中记录数，返回数组
		getCheckList : function(objName){
			var checkedBox = $("input[name="+objName+"]:checked");
			if(!checkedBox || !checkedBox.length){
				alert("请至少选择一条记录！");
				return false;
			}
			var list = this._getCheckValue(checkedBox);
			checkedBox=null;
			return list;
		},
		
		//更新CheckBox状态
		changeCheckBox : function(checkAllId, checkboxName, flag){
			if(flag) return;	//如果是选中Checkbox则不对全选Checkbox做处理
			var checkedNum=$("input[name="+checkboxName+"]:checked");
			if(!checkedNum || !checkedNum.length){
				$("#"+checkAllId).prop("checked", flag);
			}
		}
		
	};
	for(var k in pageload){
		window[k]=pageload[k];
	}
	JFT.PageBind = pageBind;
	JFT.BtnBind = btnBind;
	JFT.TableBind = dataBind;
})(JFT);

$(function(){
	var btnBindEl = $("button["+JFT.BtnBind.btnBind+"],input[type=button]["+JFT.BtnBind.btnBind+"]");
	var tblBindEl = $("table[bind=table]");
	var pageEl = $("#PAGE_PART[bind=page]");
	if(btnBindEl && btnBindEl.length){
		btnBindEl.click(JFT.BtnBind.initFuncBtnEvent);
		btnBindEl.each(function(index, element) {
			var bindArea = $(element).attr("bindForm");
			if(!bindArea || JFT.isBlank(bindArea)) return false; 
            $("#"+bindArea).find("input,textarea,select").blur(function(){
				if($(this).hasClass("e_error")){
					$(this).removeClass("e_error");
				}
			});
        });
	}
	//列表绑定
	if(tblBindEl && tblBindEl.length){
		//绑定表格记录
		var checkboxName = tblBindEl.attr("checkboxName");
		var checkAllId = tblBindEl.attr("checkAllId");
		tblBindEl.find("tbody tr").click(function(event){
			//如果不是默认INPUT事件
			var clickObj = (event.target.nodeName).toUpperCase();
			if(clickObj != "TD"){
				return;
			}
			JFT.TableBind.initTableEvent(checkAllId, checkboxName, $(this));
		});	
		//全选事件
		$("#"+checkAllId).click(function(){
			var flag = $(this).prop("checked")? true: false;
			$("input[name="+checkboxName+"]").prop("checked", flag);
			if(flag){
				tblBindEl.find("tbody>tr").addClass("selected");
			}else{
				tblBindEl.find("tbody>tr").removeClass("selected");
			}	
		});
		
		//表格数据中checkbox事件
		$("input[name="+checkboxName+"]").click(function(){
			var flag = $(this).prop("checked")? true: false;
			JFT.TableBind.changeTrStyle($(this).parent().parent() , flag);
			JFT.TableBind.changeCheckBox(checkAllId, checkboxName,flag);
		});
	}

	//分页绑定
	if(pageEl && pageEl.length){
		JFT.PageBind.initPageEvent();
	}
	
});